<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>foreach函数</title>
</head>
<body>
  <script>
    var arr = [1,2,3,4];
    arr.forEach(function (value,index,array) {
      console.log(value); //元素值
      console.log(index);//索引
      console.log(array); //数组本身
    })
  </script>
</body>
</html>